// created by noellynch
// Mar 10, 2011

package com.apachepivot.utils.applications;

import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Frame;

abstract	public class BaseDesktopApplication implements Application {
	
	@Override
	public void resume() throws Exception {
	}

	@Override
	public boolean shutdown(boolean arg0) throws Exception {
		return false;
	}

	@Override
	public void startup(Display arg0, Map<String, String> arg1) throws Exception {
	}

	@Override
	public void suspend() throws Exception {
	}
	
	static	public	void	desktopMain(Class<? extends Application> cl_class, Properties cl_props) {
		DesktopApplicationContext.main(cl_class, cl_props.toParameterArray());
	}
	
	static	public	class	Properties {
		private		int			mi_width;
		private		int			mi_height;
		private		boolean		mb_fullScreen;
		private		boolean		mb_decorated;
		private		boolean		mb_centered;
		
		public Properties(int miWidth, int miHeight, boolean mbFullScreen,
				boolean mbDecorated, boolean mbCentered) {
			super();
			mi_width = miWidth;
			mi_height = miHeight;
			mb_fullScreen = mbFullScreen;
			mb_decorated = mbDecorated;
			mb_centered = mbCentered;
		}

		public int getWidth() {
			return mi_width;
		}
		
		public void setWidth(int miWidth) {
			mi_width = miWidth;
		}
		
		public int getHeight() {
			return mi_height;
		}
		
		public void setHeight(int miHeight) {
			mi_height = miHeight;
		}
		
		public boolean isFullScreen() {
			return mb_fullScreen;
		}
		
		public void setFullScreen(boolean mbFullScreen) {
			mb_fullScreen = mbFullScreen;
		}
		
		public boolean isDecorated() {
			return mb_decorated;
		}
		
		public void setDecorated(boolean mbDecorated) {
			mb_decorated = mbDecorated;
		}
		
		public boolean isCentered() {
			return mb_centered;
		}
		
		public void setCentered(boolean mbCentered) {
			mb_centered = mbCentered;
		}
		
		public	String[]	toParameterArray() {
			//new String[] { "--fullScreen=false", "--width=800", "--height=600", "--center=true", "--undecorated=false"});
			return new String[]{ value("width", mi_width), value("height", mi_height), value("fullScreen", mb_fullScreen), value("center", mb_centered), value("undecorated", mb_decorated) };
		}
			
		private	String	value(String str_name, Object cl_value) {
			return "--" + str_name + "=" + cl_value.toString();
		}
	}
}
